package com.sc.nft.admin.controller;

import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.dto.MerchantUserDaoAddUserAndDaoRelationshipDTO;
import com.sc.nft.dto.MerchantUserDaoPageDTO;
import com.sc.nft.dto.MerchantUserDaoRemoveDTO;
import com.sc.nft.feign.MerchantUserDaoClient;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import com.sc.nft.vo.MerchantUserDaoPageVO;
import com.sc.nft.vo.SpecifyTheDaoToRemoveTheAccountDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商户和dao关联表(MerchantUserDao)表控制层
 *
 * @author wwc
 * @since 2023-03-28 11:05:29
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("admin/merchantUserDao")
@Api(tags = "商户和dao关联表")
public class MerchantUserDaoController {

    /**
     * 服务对象
     */
    private final MerchantUserDaoClient merchantUserDaoClient;

    @ApiOperation(value = "新增用户和dao的关系", notes = "新增用户和dao的关系", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/addUserAndDaoRelationship", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result addUserAndDaoRelationship(@RequestBody @Validated MerchantUserDaoAddUserAndDaoRelationshipDTO merchantUserDaoAddUserAndDaoRelationshipDTO) {
        return merchantUserDaoClient.addUserAndDaoRelationship(merchantUserDaoAddUserAndDaoRelationshipDTO);
    }

    @ApiOperation(value = "获取dao列表用户", notes = "获取dao列表用户", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/page", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<MerchantUserDaoPageVO> page(@RequestBody @Validated MerchantUserDaoPageDTO merchantUserDaoPageDTO) {
        return merchantUserDaoClient.page(merchantUserDaoPageDTO);
    }

    @ApiOperation(value = "指定dao移除账号", notes = "获取dao列表用户", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/remove", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result remove(@RequestBody @Validated MerchantUserDaoRemoveDTO merchantUserDaoRemoveDTO) {
        return merchantUserDaoClient.remove(merchantUserDaoRemoveDTO);
    }

    @ApiOperation(value = "禁用指定dao下账号", notes = "禁用指定dao下账号", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/specifyTheDaoToRemoveTheAccount", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result specifyTheDaoToRemoveTheAccount(@RequestBody @Validated SpecifyTheDaoToRemoveTheAccountDTO specifyTheDaoToRemoveTheAccountDTO) {
        return  merchantUserDaoClient.specifyTheDaoToRemoveTheAccount(specifyTheDaoToRemoveTheAccountDTO);
    }

}
